

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/egg.png">
  <link rel="icon" href="/img/egg.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="十一的蛋炒饭">
  <meta name="keywords" content="">
  
    <meta name="description" content="问题描述123456789101112131415CREATE DATABASE v2_user;CREATE TABLE &#96;v2_user&#96;  (                            &#96;id&#96; bigint NOT NULL AUTO_INCREMENT,                            &#96;code&#96; varchar(255) CHARACTER SET">
<meta property="og:type" content="article">
<meta property="og:title" content="BUG记录2 | MySQL 5.7 插入中文数据报错">
<meta property="og:url" content="http://example.com/2022/05/05/BUG%E8%AE%B0%E5%BD%952-BUG%E8%AE%B0%E5%BD%952-MySQL-5-7-%E6%8F%92%E5%85%A5%E4%B8%AD%E6%96%87%E6%95%B0%E6%8D%AE%E6%8A%A5%E9%94%99/index.html">
<meta property="og:site_name" content="十一的蛋炒饭的博客">
<meta property="og:description" content="问题描述123456789101112131415CREATE DATABASE v2_user;CREATE TABLE &#96;v2_user&#96;  (                            &#96;id&#96; bigint NOT NULL AUTO_INCREMENT,                            &#96;code&#96; varchar(255) CHARACTER SET">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071632606.png">
<meta property="og:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071633990.png">
<meta property="og:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071634608.png">
<meta property="og:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071634493.png">
<meta property="og:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071634231.png">
<meta property="article:published_time" content="2022-05-05T08:35:00.000Z">
<meta property="article:modified_time" content="2024-03-07T08:41:24.090Z">
<meta property="article:author" content="十一的蛋炒饭">
<meta property="article:tag" content="BUG">
<meta property="article:tag" content="MySQL">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071632606.png">
  
  
  
  <title>BUG记录2 | MySQL 5.7 插入中文数据报错 - 十一的蛋炒饭的博客</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.7","typing":{"enable":true,"typeSpeed":60,"cursorChar":"","loop":false,"scope":["home"]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":"§"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 7.1.1"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>十一的蛋炒饭 的博客</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/" target="_self">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/" target="_self">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/" target="_self">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/" target="_self">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/" target="_self">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/win7.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle">BUG记录2 | MySQL 5.7 插入中文数据报错</span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-05-05 16:35" pubdate>
          2022年5月5日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          315 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          3 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar category-bar" style="margin-right: -1rem">
    





<div class="category-list">
  
  
    
    
    
    <div class="category row nomargin-x">
      <a class="category-item 
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="BUG记录"
        id="heading-0f1d5bb5082794cf7cb4073845daf444" role="tab" data-toggle="collapse" href="#collapse-0f1d5bb5082794cf7cb4073845daf444"
        aria-expanded="true"
      >
        BUG记录
        <span class="list-group-count">(13)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse show" id="collapse-0f1d5bb5082794cf7cb4073845daf444"
           role="tabpanel" aria-labelledby="heading-0f1d5bb5082794cf7cb4073845daf444">
        
        
          
  <div class="category-post-list">
    
    
      
      
        <a href="/2022/05/03/BUG%E8%AE%B0%E5%BD%951-BUG%E8%AE%B0%E5%BD%951-Vmware%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%BD%91%E7%BB%9C%E5%A4%B1%E6%95%88%EF%BC%8Cifconfig%E4%B8%AD%E7%BC%BA%E5%B0%91ens33/" title="BUG记录1 | BUG记录1 Vmware虚拟机网络失效，ifconfig中缺少ens33"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录1 | BUG记录1 Vmware虚拟机网络失效，ifconfig中缺少ens33</span>
        </a>
      
    
      
      
        <a href="/2022/05/05/BUG%E8%AE%B0%E5%BD%952-BUG%E8%AE%B0%E5%BD%952-MySQL-5-7-%E6%8F%92%E5%85%A5%E4%B8%AD%E6%96%87%E6%95%B0%E6%8D%AE%E6%8A%A5%E9%94%99/" title="BUG记录2 | MySQL 5.7 插入中文数据报错"
           class="list-group-item list-group-item-action
           active">
          <span class="category-post">BUG记录2 | MySQL 5.7 插入中文数据报错</span>
        </a>
      
    
      
      
        <a href="/2022/05/07/BUG%E8%AE%B0%E5%BD%953-Mysql5-7-%E5%88%9B%E5%BB%BA%E8%A1%A8%E6%97%B6%E6%98%BE%E7%A4%BA-ERROR-1273-HY000-Unknown-collation-utf8mb4-0900-ai-ci/" title="BUG记录3 | Mysql5.7 创建表时显示 ERROR 1273 (HY000): Unknown collation: &#39;utf8mb4_0900_ai_ci&#39;"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录3 | Mysql5.7 创建表时显示 ERROR 1273 (HY000): Unknown collation: &#39;utf8mb4_0900_ai_ci&#39;</span>
        </a>
      
    
      
      
        <a href="/2022/05/08/BUG%E8%AE%B0%E5%BD%954-Xshell7%E6%97%A0%E6%B3%95%E6%89%98%E6%96%87%E4%BB%B6%E5%88%B0%E7%BB%88%E7%AB%AF/" title="BUG记录4 | Xshell7无法托文件到终端"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录4 | Xshell7无法托文件到终端</span>
        </a>
      
    
      
      
        <a href="/2022/05/12/BUG%E8%AE%B0%E5%BD%955-SSH%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E6%9C%AA%E6%8F%90%E7%A4%BA%E8%BE%93%E5%85%A5%E5%AF%86%E7%A0%81%E7%9B%B4%E6%8E%A5%E6%8A%A5%E9%94%99-ssh-connect-to-host-uni1-port-22-Connection-refused/" title="BUG记录5 | SSH远程连接未提示输入密码直接报错 ssh: connect to host uni1 port 22: Connection refused"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录5 | SSH远程连接未提示输入密码直接报错 ssh: connect to host uni1 port 22: Connection refused</span>
        </a>
      
    
      
      
        <a href="/2022/05/12/BUG%E8%AE%B0%E5%BD%956-Hadoop3-2-3-%E6%89%A7%E8%A1%8C%E5%AE%98%E6%96%B9%E5%AE%9E%E4%BE%8BMR%E8%BF%90%E8%A1%8C%E6%97%B6-%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF-%E6%89%BE%E4%B8%8D%E5%88%B0%E6%88%96%E6%97%A0%E6%B3%95%E5%8A%A0%E8%BD%BD%E4%B8%BB%E7%B1%BB/" title="BUG记录6 | Hadoop3.2.3 执行官方实例MR运行时 出现错误: 找不到或无法加载主类"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录6 | Hadoop3.2.3 执行官方实例MR运行时 出现错误: 找不到或无法加载主类</span>
        </a>
      
    
      
      
        <a href="/2022/05/12/BUG%E8%AE%B0%E5%BD%957-%E4%BD%BF%E7%94%A8-Bootstrap4-%E6%97%B6%EF%BC%8C%E5%AF%BC%E8%88%AA%E6%A0%8F%E8%80%81%E6%98%AF%E8%87%AA%E5%8A%A8%E6%8A%98%E5%8F%A0/" title="BUG记录7 | 使用 Bootstrap4 时，导航栏老是自动折叠"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录7 | 使用 Bootstrap4 时，导航栏老是自动折叠</span>
        </a>
      
    
      
      
        <a href="/2022/05/15/BUG%E8%AE%B0%E5%BD%958-python3-9%E5%AF%BC%E5%85%A5pandas%E5%BA%93%E6%97%B6%E6%8A%A5%E9%94%99%E6%89%BE%E4%B8%8D%E5%88%B0%E6%8C%87%E5%AE%9A%E7%9A%84%E6%A8%A1%E5%9D%97/" title="BUG记录8 | python3.9导入pandas库时报错找不到指定的模块"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录8 | python3.9导入pandas库时报错找不到指定的模块</span>
        </a>
      
    
      
      
        <a href="/2022/05/19/BUG%E8%AE%B0%E5%BD%959-Maven%E5%A4%9A%E6%A8%A1%E5%9D%97%E5%BC%80%E5%8F%91%E6%89%93%E5%8C%85%E7%88%B6%E6%A8%A1%E5%9D%97%E6%97%B6%E6%8A%A5%E9%94%99/" title="BUG记录9 | Maven多模块开发打包父模块时报错"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录9 | Maven多模块开发打包父模块时报错</span>
        </a>
      
    
      
      
        <a href="/2022/05/19/BUG%E8%AE%B0%E5%BD%9510-Maven%E5%A4%9A%E6%A8%A1%E5%9D%97%E5%BC%80%E5%8F%91-SpringBoot%E6%89%93%E5%8C%85%E7%88%B6%E6%A8%A1%E5%9D%97pom%E9%A1%B9%E7%9B%AE%E6%97%B6-%E6%8A%A5%E9%94%99-Unable-to-find-main-class%E3%80%82/" title="BUG记录10 | Maven多模块开发 SpringBoot打包父模块pom项目时 报错 Unable to find main class"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录10 | Maven多模块开发 SpringBoot打包父模块pom项目时 报错 Unable to find main class</span>
        </a>
      
    
      
      
        <a href="/2022/05/19/BUG%E8%AE%B0%E5%BD%9511-SpringBoot%E5%A4%9A%E6%A8%A1%E5%9D%97%E5%BC%80%E5%8F%91Web%E6%97%B6%EF%BC%8C%E6%89%BE%E4%B8%8D%E5%88%B0controller%E5%B1%82%E7%9A%84%E7%B1%BB%EF%BC%8C%E6%8A%A5%E9%94%99-Request-processing-failed-nested-exception-is-org-thymeleaf-exceptions/" title="BUG记录11 | SpringBoot多模块开发Web时，找不到controller层的类，报错 Request processing failed; nested exception is org.thymeleaf.exceptions"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录11 | SpringBoot多模块开发Web时，找不到controller层的类，报错 Request processing failed; nested exception is org.thymeleaf.exceptions</span>
        </a>
      
    
      
      
        <a href="/2024/03/15/BUG%E8%AE%B0%E5%BD%9514-%E4%BD%BF%E7%94%A8-MyBatis-%E6%9F%A5%E8%AF%A2%E4%B8%8D%E5%88%B0%E6%95%B0%E6%8D%AE%E5%BA%93%E9%87%8C%E7%9A%84%E4%B8%AD%E6%96%87%E6%95%B0%E6%8D%AE/" title="BUG记录14 | 使用 MyBatis 查询不到数据库里的中文数据"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录14 | 使用 MyBatis 查询不到数据库里的中文数据</span>
        </a>
      
    
      
      
        <a href="/2024/03/19/BUG%E8%AE%B0%E5%BD%9515-%E5%89%8D%E5%90%8E%E7%AB%AF%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98/" title="BUG记录15 | 前后端跨域问题"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">BUG记录15 | 前后端跨域问题</span>
        </a>
      
    
  </div>

        
      </div>
    </div>
  
</div>


  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">BUG记录2 | MySQL 5.7 插入中文数据报错</h1>
            
              <p id="updated-time" class="note note-info" style="display: none">
                
                  
                    本文最后更新于 2024-03-07T16:41:24+08:00
                  
                  

                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="问题描述"><a href="#问题描述" class="headerlink" title="问题描述"></a>问题描述</h1><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">CREATE</span> DATABASE v2_user;<br><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> `v2_user`  (<br>                            `id` <span class="hljs-type">bigint</span> <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> AUTO_INCREMENT,<br>                            `code` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8 <span class="hljs-keyword">COLLATE</span> utf8_general_ci <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;用户编码&#x27;</span>,<br>                            `username` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8 <span class="hljs-keyword">COLLATE</span> utf8_general_ci <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;用户名称&#x27;</span>,<br>                            `password` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8 <span class="hljs-keyword">COLLATE</span> utf8_general_ci <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;用户密码（带密文）&#x27;</span>,<br>                            `gender` <span class="hljs-type">int</span> <span class="hljs-keyword">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;性别（1: 女, 2:男）&#x27;</span>,<br>                            `birthday` <span class="hljs-type">date</span> <span class="hljs-keyword">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;生日&#x27;</span>,<br>                            `phone` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8 <span class="hljs-keyword">COLLATE</span> utf8_general_ci <span class="hljs-keyword">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">NULL</span>,<br>                            `address` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8 <span class="hljs-keyword">COLLATE</span> utf8_general_ci <span class="hljs-keyword">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;地址&#x27;</span>,<br>                            `pwd` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8 <span class="hljs-keyword">COLLATE</span> utf8_general_ci <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;用户密码（明文）&#x27;</span>,<br>                            `salt` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8 <span class="hljs-keyword">COLLATE</span> utf8_general_ci <span class="hljs-keyword">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;盐&#x27;</span>,<br>                            `img` mediumtext <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8 <span class="hljs-keyword">COLLATE</span> utf8_general_ci <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">&#x27;用户头像&#x27;</span>,<br>                            <span class="hljs-keyword">PRIMARY</span> KEY (`id`) <span class="hljs-keyword">USING</span> BTREE<br>) ENGINE <span class="hljs-operator">=</span> InnoDB AUTO_INCREMENT <span class="hljs-operator">=</span> <span class="hljs-number">16</span> <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> <span class="hljs-operator">=</span> utf8 <span class="hljs-keyword">COLLATE</span> <span class="hljs-operator">=</span> utf8_general_ci ROW_FORMAT <span class="hljs-operator">=</span> <span class="hljs-keyword">Dynamic</span>;<br></code></pre></td></tr></table></figure>

<p>ERROR 1366 (HY000): Incorrect string value: ‘\xD3\xC8\xC4\xE3’ for column ‘username’ at row 1</p>
<p>尝试解决1：</p>
<p>1）在mysql  shell 中查看当前数据库的所有编码格式</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">show variables like &#x27;character%&#x27;;<br></code></pre></td></tr></table></figure>

<p><img src="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071632606.png" srcset="/img/loading.gif" lazyload alt="image-20240307163230553"></p>
<p>修改两个为latin1的 database 和 server</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">set character_set_database=utf8;<br>set character_set_server=utf8;<br></code></pre></td></tr></table></figure>

<p>亲测，没有作用。</p>
<h1 id="最终解决"><a href="#最终解决" class="headerlink" title="最终解决"></a>最终解决</h1><p>修改mysql的配置文件my.inf</p>
<p>MySQL 5.7 的默认安装目录：C:\Program Files (x86)\MySQL\MySQL Server 5.7</p>
<p>可能是版本问题，根目录下没有 my.ini这个文件</p>
<p><img src="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071633990.png" srcset="/img/loading.gif" lazyload alt="image-20240307163348933"></p>
<p>只好新建一个了，内容如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs plain">[client]<br>default-character-set=utf8<br><br>[mysql]<br>default-character-set=utf8<br><br>[mysqld]<br>datadir=C:\Program Files (x86)\MySQL\MySQL Server 5.7\data<br>character-set-server=utf8<br>collation-server=utf8_general_ci<br></code></pre></td></tr></table></figure>

<p>windows下重启mysql</p>
<p>首先win+R输入 <strong>services.msc</strong> </p>
<p>快速进入系统的服务管理，找到MySQL 然后重启</p>
<p><img src="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071634608.png" srcset="/img/loading.gif" lazyload alt="image-20240307163408552"></p>
<p>最后，重新连接mysql，插入中文数据成功</p>
<p><img src="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071634493.png" srcset="/img/loading.gif" lazyload alt="image-20240307163429458"></p>
<p>再次查询数据库的编码看看：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">show variables like &#x27;character%&#x27;;<br></code></pre></td></tr></table></figure>

<p><img src="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403071634231.png" srcset="/img/loading.gif" lazyload alt="image-20240307163444187"></p>
<p>说明 database 和 server的编码为 latin1 是不影响插入中文的…</p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/BUG%E8%AE%B0%E5%BD%95/" class="category-chain-item">BUG记录</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/BUG/" class="print-no-link">#BUG</a>
      
        <a href="/tags/MySQL/" class="print-no-link">#MySQL</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>BUG记录2 | MySQL 5.7 插入中文数据报错</div>
      <div>http://example.com/2022/05/05/BUG记录2-BUG记录2-MySQL-5-7-插入中文数据报错/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>十一的蛋炒饭</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年5月5日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/05/07/BUG%E8%AE%B0%E5%BD%953-Mysql5-7-%E5%88%9B%E5%BB%BA%E8%A1%A8%E6%97%B6%E6%98%BE%E7%A4%BA-ERROR-1273-HY000-Unknown-collation-utf8mb4-0900-ai-ci/" title="BUG记录3 | Mysql5.7 创建表时显示 ERROR 1273 (HY000): Unknown collation: &#39;utf8mb4_0900_ai_ci&#39;">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">BUG记录3 | Mysql5.7 创建表时显示 ERROR 1273 (HY000): Unknown collation: &#39;utf8mb4_0900_ai_ci&#39;</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/05/03/BUG%E8%AE%B0%E5%BD%951-BUG%E8%AE%B0%E5%BD%951-Vmware%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%BD%91%E7%BB%9C%E5%A4%B1%E6%95%88%EF%BC%8Cifconfig%E4%B8%AD%E7%BC%BA%E5%B0%91ens33/" title="BUG记录1 | BUG记录1 Vmware虚拟机网络失效，ifconfig中缺少ens33">
                        <span class="hidden-mobile">BUG记录1 | BUG记录1 Vmware虚拟机网络失效，ifconfig中缺少ens33</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>博客网站基于Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>主题Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>





  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  var relativeDate = function() {
    var updatedTime = document.getElementById('updated-time');
    if (updatedTime) {
      var text = updatedTime.textContent;
      var reg = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-]\d{2}:\d{2})/;
      var matchs = text.match(reg);
      if (matchs) {
        var relativeTime = moment(matchs[0]).fromNow();
        updatedTime.textContent = text.replace(reg, relativeTime);
      }
      updatedTime.style.display = '';
    }
  };
  Fluid.utils.createScript('https://lib.baomitu.com/moment.js/2.29.4/moment.min.js', function() {
    if (!'zh-cn'.startsWith('en')) {
      Fluid.utils.createScript('https://lib.baomitu.com/moment.js/2.29.4/locale/zh-cn.min.js', function() {
        relativeDate();
      });
    } else {
      relativeDate();
    }
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
